package com.jzo2o.foundations.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.checkerframework.checker.units.qual.C;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class EsConfiguration {

    @Value("${jzo2o.es.host}")
    private String host;
    @Value("${jzo2o.es.port}")
    private Integer post;
    @Bean
    public RestHighLevelClient restHighLevelClient(){
        log.info("初始化es连接");
        return new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(host,post,"http")
                )
        );
    }
}
